<?php
declare (strict_types=1);
namespace app\serviceapp;

use app\model\BaseModel;
use app\model\Feedback as FeedbackModel;
use think\facade\Db;

/**
 * 反馈建议
 * Class FeedbackService
 * @package app\serviceapp
 */
class FeedbackService
{
    /**
     * 提交建议
     * @param array $param 入库数组
     * @return array json
     */
    public static function submitContents($param)
    {
        BaseModel::beginTrans();
        try {
            $feedback = new FeedbackModel();
            $feedback->user_id = $param['userId'];
            $feedback->mobile = $param['mobile'];
            $feedback->content = $param['content'];
            $feedback->create_time = date('Y-m-d H:i:s', time());
            $feedback->save();
        } catch (\Exception $e) {
            BaseModel::rollbackTrans();
            return json_error(100, $e->getMessage());
        }
        BaseModel::commitTrans();
        return json_ok((object)array(), 0);
    }

}
